#!/usr/bin/env php
<?php

# A worker that listens on the 'work' function, and when a job
# is received, it sleeps 10 ms and responds with the payload
# mulitplied by two.

$worker = new GearmanWorker();
$worker->addServer('127.0.0.1', 4730);
$worker->addFunction('work', 'work_callback');
while (@$worker->work());

function work_callback($job)
{
  usleep(10000);
  return $job->workload() * 2;
}

?>
